<%@page import="entities.Template"%>
<%@page import="java.util.List"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory"%>
<%@page import="com.google.appengine.api.blobstore.BlobstoreService"%>
<%@page import="entities.ApplicationTemplate"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.UrlHelper"%>

<%
TreeMap check = (TreeMap) request.getAttribute("check");
String success = (String) request.getAttribute("success");
ApplicationTemplate template = (ApplicationTemplate) request.getAttribute("template");
String form = (String) request.getAttribute("form");
List<Template> templates = (List<Template>) request.getAttribute("templates");
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/admin/layouts/header.jsp" />
		
<script type="text/javascript" src="/admin/js/custom/application_template_form.js"></script>
		
					<!-- Content Area -->
                	<div id="da-content-area">
                		<jsp:include page="/admin/elements/message_box.jsp" />
                        
                		<div class="grid_4">
                        	<div class="da-panel">
                            	<div class="da-panel-header">
                                	<span class="da-panel-title">
                                        <img src="/admin/images/icons/black/16/pencil.png" alt="" />
                                        Add New Application Template
                                    </span>
                                    
                                </div>
                                <div class="da-panel-content">
                                	<form class="da-form" method="post">
                                    	<div class="da-form-inline">
                                    		<div class="da-form-row">
                                                <label>Title <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                    <input type="text" name="title" value="<%=template.getTitle() %>" class="<%=check.get("title") != null ? "error" : "" %>"/>
                                                    <% if (check.get("title") != null) { %>
                                                    <span class="errorMessage"><%=check.get("title") %></span>
                                                    <% } %>
                                                </div>
                                            </div>
                                            
                                            <div class="da-form-row">
                                                <label>Description <span class="required">*</span></label>
                                                <div class="da-form-item default">
                                                    <textarea cols="auto" rows="auto" name="description" class="<%=check.get("description") != null ? "error" : "" %>" ><%=template.getDescription() %></textarea>
                                                    <% if (check.get("description") != null) { %>
                                                    <span class="errorMessage"><%=check.get("description") %></span>
                                                    <% } %>
                                                </div>
                                            </div>
                                            
                                            <div class="da-form-row">
                                                <label>Choise Template</label>
                                                <div class="da-form-item small">
													<select name="templateid" class="<%=check.get("templateid") != null ? "error" : "" %>" >
														<% for (Template temp : templates) { %>
					                            		<option value="<%=temp.getId()%>" <%=temp.getId().equals(template.getId()) ? "selected=\"selected\"" : "" %>><%=temp.getTitle() %></option>
					                            		<% } %>
													</select>
													<% if (check.get("templateid") != null) { %>
                                                    <span class="errorMessage"><%=check.get("templateid") %></span>
                                                    <% } %>
                                                </div>
                                            </div>
                                            
                                            <div class="da-button-row">
                                            	<input type="submit" value="Submit" class="da-button blue left" />
	                                        	<input type="reset" value="Reset" class="da-button gray" />
	                                        </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                	</div>

<jsp:include page="/admin/layouts/footer.jsp" />